package testenv.model.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import testenv.model.AbstractBaseEntity;




@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name="parent_id_seq", sequenceName="parent_id_sequence")
public class Parent extends AbstractBaseEntity {
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="parent_id_seq")
	@GenericGenerator(
	     name="parent_id_seq",
	     strategy="sequence",
	     parameters= {
	         @Parameter(name="minvalue", value="1"),
	         @Parameter(name="increment", value="1"),
	         @Parameter(name="sequence", value="parent_id_sequence")
	         })
	private Integer id = null;

	
	@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
	@OneToMany(mappedBy="parent", cascade=CascadeType.ALL)
	private Set<Child> childSet = new HashSet<Child>();
	
	private String name = null;

	private Integer age = null;
	
	
	public Parent() {
	}
	
	
	public Parent(String name) {
		this.name = name;
	}
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Set<Child> getChildSet() {
		return childSet;
	}

	public void setChildSet(Set<Child> childSet) {
		this.childSet = childSet;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}
	
	
}
